import java.util.Stack;

public class Solution {
    public int evalRPN(String[] tokens){
        Stack<Integer> stack=new Stack<>();
        for (int i = 0; i < tokens.length ; i++) {
            String tmp=tokens[i];
            if(!isOperations(tmp)){
                stack.push(Integer.parseInt(tmp));

            }else {
                Integer val2=stack.pop();
                Integer val1=stack.pop();
                switch (tmp){
                    case "+":
                        stack.push(val1+val2);
                        break;
                    case "-":
                        stack.push(val1-val2);
                        break;
                    case "*":
                        stack.push(val1*val2);
                        break;
                    case "/":
                        stack.push(val1/val2);
                        break;

                }

            }

        }
       return stack.pop();


    }
    public boolean isOperations(String tmp){
        if(tmp.equals("+")||tmp.equals("-")||tmp.equals("*")||tmp.equals("/")){
            return true;
        }
        return false;
    }
}
